From: Jackmcbarn Date: Tue, 17 Sep 2013 22:54:59 +0000 (-0400) Subject: Store boolean values as integers with SQLite X-Git-Tag: 1.31.0-rc.0~18747^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=1eca78131b11b10341ec5c4630f34ffedf075c0f;p=lhc%2Fweb%2Fwiklou.git Store boolean values as integers with SQLite Since SQLite doesn't have a boolean type, and doesn't enforce types, make sure booleans get stored as integers, to prevent undesirable behavior, such as false values being stored as empty strings. Change-Id: I2a96065826412fa25f98ec298d806e73ebe155ba --- diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index 6692fa40ac..a8270bf4b3 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -709,6 +709,8 @@ class DatabaseSqlite extends DatabaseBase { function addQuotes( $s ) { if ( $s instanceof Blob ) { return "x'" . bin2hex( $s->fetch() ) . "'"; + } elseif ( is_bool( $s ) ) { + return (int)$s; } elseif ( strpos( $s, "\0" ) !== false ) { // SQLite doesn't support \0 in strings, so use the hex representation as a workaround. // This is a known limitation of SQLite's mprintf function which PDO should work around,